package org.gwtEss.other;

import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM;

public class MyPopupPanel extends Div{
	private int leftPosition;
	private int topPosition;

	public MyPopupPanel() {
		super();
		DOM.setStyleAttribute(getElement(), "position", "absolute");
	}
	
	  public void setPopupPosition(int left, int top) {
		    // Save the position of the popup
		    leftPosition = left;
		    topPosition = top;

		    // Account for the difference between absolute position and the
		    // body's positioning context.
		    left -= Document.get().getBodyOffsetLeft();
		    top -= Document.get().getBodyOffsetTop();

		    // Set the popup's position manually, allowing setPopupPosition() to be
		    // called before show() is called (so a popup can be positioned without it
		    // 'jumping' on the screen).
		    Element elem = getElement();
		    elem.getStyle().setPropertyPx("left", left);
		    elem.getStyle().setPropertyPx("top", top);
		  }
}